const a = function (_, d, { xe: { get, pluck }, dc: { store }, dayjs }) {
  const items = get(d, "data.items", []);
  if (!items.length) return {};
  console.log("单位支出前十chart data: ", items);
  items.forEach((i) => {
    i.YS = ((i.YS || 0) / 10000).toFixed(2);
    i.ZC = ((i.ZC || 0) / 10000).toFixed(2);
    i.ZXL = ((i.ZXL || 0) * 100).toFixed(1);
    i.ENTERPRISENAME = (i.ENTERPRISENAME || "")
      .replace("中共杭州市余杭", "")
      .replace("杭州市余杭区", "")
      .replace("余杭区", "");
  });
  const now = dayjs();
  const year = now.year();
  const yearStore = Number(dayjs(store.get("user", "date")).format("YYYY"));
  let sx;
  if (yearStore !== year) {
    sx = 100;
  } else {
    const isLeapYear = (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
    const startOfYear = dayjs().startOf("year");
    const dayOfYear = now.diff(startOfYear, "day") + 1;
    const totalDays = isLeapYear ? 366 : 365;
    const timeliness = ((dayOfYear / totalDays) * 100).toFixed(1);
    sx = timeliness;
  }
  return {
    tooltip: {
      trigger: "axis",
      axisPointer: { type: "shadow", label: { backgroundColor: "#283b56" } },
    },
    legend: {},
    grid: { containLabel: true, top: 80, left: 20, right: 10, bottom: 20 },
    xAxis: {
      type: "category",
      boundaryGap: true,
      data: pluck(items, "ENTERPRISENAME"),
      axisLabel: { rotate: 20 },
    },
    yAxis: [
      { type: "value", name: "单位: 万元" },
      { type: "value", name: "单位: %" },
    ],
    series: [
      {
        name: "预算",
        type: "bar",
        stack: "YS",
        data: pluck(items, "YS"),
        label: { show: true, position: "top" },
      },
      {
        name: "支出",
        type: "bar",
        stack: "ZC",
        data: pluck(items, "ZC"),
        label: { show: true, position: "top" },
      },
      {
        name: "执行率",
        type: "line",
        data: pluck(items, "ZXL"),
        yAxisIndex: 1,
      },
      {
        name: "时序",
        type: "line",
        data: pluck(items, "YS").map((i) => sx),
        lineStyle: { type: "dashed" },
        yAxisIndex: 1,
      },
    ],
  };
};
